namespace SampleApp.Tests {
    using Microsoft.Services.TestTools.UITesting.Html;
    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using SampleApp.Tests.Pages;

    [CodedUITest]
    public class AccountRegistrationTests : PageTest<Home> {

        [TestInitialize]
        public override void Initialize() {
            base.Initialize();
            TestedPage.EnsureUserIsLoggedOff();
        }

        [TestMethod]
        public void UserIsLoggedInAfterSuccessfullAccountCreation() {
            
            string userName = Name();

            var home = TestedPage
                .NavigateToLogOn()
                .NavigateToRegistration()
                .CreateNewAccount(userName, Email(), Password());
            
            Assert.IsTrue(home.IsLoggedInUserDisplayed(userName));
        }
    }
}